<script>
	export default {
		onLaunch() {
			this.Login();
			// this.getInit();
		},
		methods: {
			async getInit() {
				const res = await this.$request({
					url: this.$api.init,
				});
				if (res.code == 1) {
					uni.setStorageSync("init", res.data);
					uni.setNavigationBarTitle({
						title: res.data.name
					})
				}
			},
			async Login() {
				let urlParams = new URLSearchParams(window.location.search);
				let code = urlParams.get("code");
				if (code) {
					const res = await this.$request({
						url: this.$api.login,
						data: {
							code,
						},
					});
					if (res.code == 1) {
						uni.setStorageSync("user", res.data);
						this.getInit();
					}
				} else {
					window.location.href =
						"https://open.weixin.qq.com/connect/oauth2/authorize?appid=wx66869b6b1adc501f&redirect_uri=https://fxcs.bjdengdeng.cn/h5&response_type=code&scope=snsapi_base#wechat_redirect";
				}
			},
		},
		onShow: function() {
			console.log("App Show");
		},
		onHide: function() {
			console.log("App Hide");
		},
	};
</script>

<style lang="scss">
	/* 注意要写在第一行，同时给style标签加入lang="scss"属性 */
	@import "@/uni_modules/uview-ui/index.scss";
	@import "@/static/css/style.css";

	// ::v-deep .uni-radio-input {
	// 	background-color: rgb(255, 126, 17) !important;
	// 	border-color: rgb(255, 126, 17) !important;
	// }
</style>